home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / SOUND / THEDECK1.ARJ / THEDECK1.BAS < prev    next >
BASIC Source File  |  1991-10-16  |  36KB  |  1,361 lines

  1. DECLARE SUB ButtonSelect (ButtonNumber%, OnOff%)
  2. DECLARE SUB ClearButtons (first%, last%)
  3. DECLARE SUB DelayOnPort (times%)
  4. DECLARE SUB DemoInit ()
  5. DECLARE SUB DoHelpInfo ()
  6. DECLARE SUB DoLoadMIDI ()
  7. DECLARE SUB DoLoadVOC ()
  8. DECLARE SUB DoPauseMIDI (OnOff%)
  9. DECLARE SUB DoPauseVOC (OnOff%)
  10. DECLARE SUB DoPlayMIDI ()
  11. DECLARE SUB DoPlayVoc ()
  12. DECLARE SUB DoRecordVOC ()
  13. DECLARE SUB DoScreenMIDI ()
  14. DECLARE SUB DoStopMIDI ()
  15. DECLARE SUB DoStopVOC ()
  16. DECLARE SUB DrawPanel ()
  17. DECLARE SUB FlashButton ()
  18. DECLARE SUB GetInput (prompt$, answer$)
  19. DECLARE FUNCTION GetKeyPick% (waitfor%)
  20. DECLARE FUNCTION GetMousePick% (MouseButtonState%)
  21. DECLARE SUB MouseFunc (func%, IM AS ANY, OM AS ANY)
  22. DECLARE SUB MouseOnOff (OnOff%)
  23. DECLARE FUNCTION SelectEvent% ()
  24. DECLARE SUB SetAutoPlay ()
  25. DECLARE SUB SetColor (fore%, back%)
  26. DECLARE SUB SetLocate (row%, col%)
  27. DECLARE SUB SetPrint (strg$, CR%)
  28. DECLARE SUB SoundEffects (effnumber%)
  29.  
  30. 'in QBXSNDxx.QLB only
  31. DECLARE SUB INTERRUPTX (intnum%, ireg AS ANY, oreg AS ANY)
  32.  
  33. REM $INCLUDE: 'QBXSOUND.BI'
  34.  
  35. DEFINT A-Z
  36. 'TheDECK (C)1991 Cornel Huth - All Rights Reserved
  37. '16-Oct-91
  38. 'C>bc playdemo /o/e/ah/v
  39.  
  40. '----
  41. TYPE ButtonInfoTYPE
  42. x0 AS INTEGER   'col
  43. y0 AS INTEGER   'row
  44. xs AS INTEGER   'cols
  45. ys AS INTEGER   'rows
  46. END TYPE
  47.  
  48. TYPE RegTYPEx   'interface structure to INTERRUPTX
  49. ax AS INTEGER
  50. bx AS INTEGER
  51. cx AS INTEGER
  52. dx AS INTEGER
  53. bp AS INTEGER
  54. si AS INTEGER
  55. di AS INTEGER
  56. flags AS INTEGER
  57. ds AS INTEGER
  58. es AS INTEGER
  59. END TYPE
  60.  
  61. TYPE MouseTYPE  'interface structure to MOUSEFUNC
  62. ax AS INTEGER
  63. bx AS INTEGER
  64. cx AS INTEGER
  65. dx AS INTEGER
  66. END TYPE
  67.  
  68. TYPE BigChunkTYPE  'for BASIC file I/O
  69. BigChunk AS STRING * 8192
  70. END TYPE
  71.  
  72. '----
  73. CONST MAXBUTTONS = 17
  74.  
  75. DIM SHARED gActiveButton
  76. DIM SHARED gFG          'color tracker
  77. DIM SHARED gBG          'color tracker
  78. DIM SHARED gRow         'row tracker (ni)
  79. DIM SHARED gCol         'col tracker (ni)
  80. DIM SHARED gMouse       '1=use mouse also
  81. DIM SHARED gFMinit      '1=FM capable
  82. DIM SHARED gMIDIinit    '1=MIDI init'ed
  83. DIM SHARED gVOCinit     '1=VOC capable and init'ed
  84. DIM SHARED gMIDIloaded  '1=file loaded
  85. DIM SHARED gVOCloaded   '1=file loaded
  86. DIM SHARED gAutoPlay    '0=single play,1=auto MIDI,2=auto VOC,3=MIDI-VOC-MIDI...
  87.  
  88. DIM SHARED xreg AS RegTYPEx
  89. DIM SHARED IM AS MouseTYPE
  90. DIM SHARED OM AS MouseTYPE
  91.  
  92. REDIM SHARED gButtonInfo(1 TO MAXBUTTONS) AS ButtonInfoTYPE
  93. REDIM SHARED mbuff(1 TO 1) AS BigChunkTYPE
  94. REDIM SHARED vbuff(1 TO 1) AS BigChunkTYPE
  95.  
  96. DemoInit
  97. DO
  98.    IF xevent >= 0 THEN xevent = SelectEvent
  99.    IF ABS(xevent) = 13 THEN
  100.       xevent = 0
  101.       SELECT CASE gActiveButton
  102.       CASE 1    'eject (load MIDI file)
  103.          DoLoadMIDI
  104.          gMIDIloaded = 1
  105.       CASE 2    'eject (load VOC file)
  106.          DoLoadVOC
  107.          gVOCloaded = 1
  108.       '-----
  109.       CASE 3    'rewind MIDI (restart)
  110.          IF gMIDIloaded THEN SoundEffects 1
  111.          ClearButtons 3, 3
  112.          DoPlayMIDI
  113.          stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  114.          IF stat THEN
  115.             ButtonSelect 4, 1
  116.             gActiveButton = 4
  117.             MIDIpause = 0
  118.             MIDIstarted = 1
  119.          END IF
  120.       CASE 4    'play MIDI
  121.          DoPlayMIDI
  122.          stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  123.          IF stat THEN
  124.             MIDIpause = 0
  125.             MIDIstarted = 1
  126.          END IF
  127.       CASE 5    'FF MIDI
  128.          SoundEffects 2
  129.          ClearButtons 5, 5
  130.          'not implemented
  131.       CASE 6    'stop MIDI
  132.          DoStopMIDI
  133.          MIDIpause = 0
  134.          MIDIstarted = 0
  135.       CASE 7    'pause/cont MIDI
  136.          MIDIpause = NOT MIDIpause
  137.          DoPauseMIDI MIDIpause
  138.       '-----
  139.       CASE 8    'record VOC
  140.          ClearButtons 8, 8
  141.          DoRecordVOC
  142.       CASE 9    'rewind VOC (restart)
  143.          IF gVOCloaded THEN SoundEffects 1
  144.          ClearButtons 9, 9
  145.          DoPlayVoc
  146.          stat = VOCinfo(BT, SR)
  147.          IF stat THEN
  148.             ButtonSelect 10, 1
  149.             gActiveButton = 10
  150.             PauseVOC = 0
  151.             VOCstarted = 1
  152.          END IF
  153.       CASE 10   'play VOC
  154.          DoPlayVoc
  155.          stat = VOCinfo(BT, SR)
  156.          IF stat THEN
  157.             PauseVOC = 0
  158.             VOCstarted = 1
  159.          END IF
  160.       CASE 11   'FF VOC
  161.          SoundEffects 2
  162.          ClearButtons 11, 11
  163.          'not implemented
  164.       CASE 12   'stop VOC
  165.          DoStopVOC
  166.          PauseVOC = 0
  167.          VOCstarted = 0
  168.       CASE 13    'pause/cont VOC
  169.          PauseVOC = NOT PauseVOC
  170.          DoPauseVOC PauseVOC
  171.       CASE 14    'INFO
  172.          DoHelpInfo
  173.       CASE 15    'QUIT
  174.          xevent = 27
  175.       '------
  176.       'if both MIDI and VOC are autoplay then MIDI plays, the VOC, then MIDI...
  177.       CASE 16   'activate auto-play of MIDI
  178.          IF gMIDIloaded THEN
  179.             IF gAutoPlay AND 1 THEN
  180.                gAutoPlay = gAutoPlay AND &HFFFE
  181.             ELSE
  182.                gAutoPlay = gAutoPlay OR 1
  183.             END IF
  184.             SetAutoPlay
  185.          END IF
  186.       CASE 17   'activate auto-play of VOC
  187.          IF gVOCloaded THEN
  188.             IF gAutoPlay AND 2 THEN
  189.                gAutoPlay = gAutoPlay AND &HFFFD
  190.             ELSE
  191.                gAutoPlay = gAutoPlay OR 2
  192.             END IF
  193.             SetAutoPlay
  194.          END IF
  195.       CASE ELSE
  196.       END SELECT
  197.    END IF
  198.  
  199.    IF gMIDIinit THEN
  200.       stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  201.       IF stat THEN
  202.          DoScreenMIDI
  203.       ELSEIF MIDIstarted AND VOCstarted = 0 THEN
  204.          MIDIstarted = 0
  205.          xevent = -13
  206.          SELECT CASE gAutoPlay
  207.          CASE 0
  208.             xevent = 0
  209.          CASE 1
  210.             gActiveButton = 4
  211.          CASE 2
  212.             gActiveButton = 10
  213.          CASE 3
  214.             gActiveButton = 10
  215.          CASE ELSE
  216.          END SELECT
  217.       ELSEIF stat = 0 THEN
  218.          MIDIstarted = 0
  219.       END IF
  220.       IF stat = 0 THEN DoScreenMIDI
  221.    END IF
  222.  
  223.    IF gVOCinit THEN
  224.       stat = VOCinfo(BT, SR)
  225.       IF stat THEN
  226.          'DoScreenVOC
  227.       ELSEIF VOCstarted AND MIDIstarted = 0 THEN
  228.          VOCstarted = 0
  229.          xevent = -13
  230.          SELECT CASE gAutoPlay
  231.          CASE 0
  232.             xevent = 0
  233.          CASE 1
  234.             gActiveButton = 4
  235.          CASE 2
  236.             gActiveButton = 10
  237.          CASE 3
  238.             gActiveButton = 4
  239.          CASE ELSE
  240.          END SELECT
  241.       ELSEIF stat = 0 THEN
  242.          VOCstarted = 0
  243.       END IF
  244.    END IF
  245.  
  246. LOOP UNTIL xevent = 27
  247. MouseOnOff 0
  248.  
  249. ShutDown:
  250. CLOSE
  251. MouseFunc 0, IM, OM
  252. gMouse = 0
  253. LOCATE 25, 1: PRINT SPACE$(80);
  254.  
  255. IF gFMinit THEN
  256.    MusicEnd
  257.    FOR voc = 0 TO 10
  258.       NoteOff voc
  259.    NEXT
  260. END IF
  261.  
  262. IF gVOCinit THEN nix = VOCend
  263.  
  264. LOCATE 1, 1
  265. SELECT CASE ErrCode
  266. CASE 0
  267.    e$ = ""
  268. CASE 7
  269.    e$ = "File too large."
  270. CASE 52, 53, 64, 68, 75, 76
  271.    e$ = "Pathname not found."
  272. CASE 248
  273.    e$ = "SoundBlaster/compatible required for VOC."
  274. CASE 249
  275.    e$ = "AdLib/compatible required for MIDI."
  276. CASE 250
  277.    e$ = "MIDI file has more than single track."
  278. CASE ELSE
  279.    e$ = "BASIC error" + STR$(ErrCode) + ". Program ending."
  280. END SELECT
  281. PRINT e$;
  282. DelayOnPort 20000
  283. LOCATE 24, 1
  284. PRINT
  285. PRINT "TheDECK v1.00 (C)1991 Cornel Huth                                    16-Oct-1991"
  286. PRINT
  287. PRINT "This is a demonstration program for a QuickBASIC/BASIC PDS link library called"
  288. PRINT "QBXSNDxx (xx=latest version number). If you'd like to obtain the link library"
  289. PRINT "for inclusion into your own programs select the desired package level that you"
  290. PRINT "require and place an order to the address below with full payment (check, MO)."
  291. PRINT
  292. PRINT "QBXSOUND Programmer link LIB with background MIDI music, DMA VOC input/output,"
  293. PRINT "and programmer's manual on disk:"
  294. PRINT
  295. PRINT "    QuickBASIC 4.0a, 4.0b, 4.5 versions ONLY . . . . . . . $ 9.95"
  296. PRINT
  297. PRINT "QBXSOUND Professional link LIB with background MIDI music, DMA VOC input/output,"
  298. PRINT "direct FM chip access (for special sound effects), all BASIC source code for"
  299. PRINT "custom changes and BASIC 7.x custom compiler matching, plus a bound, printed"
  300. PRINT "programmer's manual:"
  301. PRINT
  302. PRINT "    QuickBASIC 4.0a, 4.0b, 4.5, and QBX/BC 7.x . . . . . . $49.95"
  303. PRINT
  304. PRINT "Check must be on a US BANK and in US DOLLARS only and payable to:"
  305. PRINT
  306. PRINT "    Cornel Huth                          CANADA and Foreign orders"
  307. PRINT "    6402 Ingram Rd.                      add $5.00 for shipping"
  308. PRINT "    San Antonio, TX 78238-3915  U.S.A";
  309. END
  310.  
  311. '----
  312. 'disk i/o error handler
  313. 'shut everything down and exit program
  314. DiskHandler:
  315. ErrCode = ERR
  316. RESUME ShutDown
  317.  
  318. '----
  319. 'button x/y positions and x/y size
  320. ButtonInfo:
  321. 'eject
  322. DATA 37,5,3,2
  323. DATA 41,5,3,2
  324. 'MIDI Track
  325. DATA  6,12,4,2
  326. DATA 11,12,6,2
  327. DATA 18,12,4,2
  328. DATA 23,12,6,2
  329. DATA 30,12,5,2
  330. 'VOC Track
  331. DATA 45,12,3,2
  332. DATA 49,12,4,2
  333. DATA 54,12,6,2
  334. DATA 61,12,4,2
  335. DATA 66,12,6,2
  336. DATA 73,12,5,2
  337. 'F1=INFO,ESC=QUIT
  338. DATA 38,17,4,2
  339. DATA 38,21,4,2
  340. 'AUTO
  341. DATA 37,7,3,2
  342. DATA 41,7,3,2
  343.  
  344. SUB ButtonSelect (ButtonNumber, OnOff)
  345.  
  346. 'select/deselect button by highlighting/normaling it
  347. 'note x's are column position info, y's are row position info
  348.  
  349. tFG = gFG
  350. tBG = gBG
  351. IF OnOff = 0 THEN SetColor 7, 0 ELSE SetColor 15, 0
  352.  
  353. x0 = gButtonInfo(ButtonNumber).x0
  354. y0 = gButtonInfo(ButtonNumber).y0
  355. xs = gButtonInfo(ButtonNumber).xs
  356. ys = gButtonInfo(ButtonNumber).ys
  357. x1 = x0 + xs - 1
  358. y1 = y0 + ys - 1
  359.  
  360. SetLocate y0, x0
  361. SetPrint "┌", 0
  362. FOR i = 1 TO xs - 2
  363.    SetPrint "─", 0
  364. NEXT
  365. SetPrint "┐", 1
  366.  
  367. FOR i = 1 TO ys - 2     'not currently needed since button height=2 (ys)
  368.    SetLocate -1, x0
  369.    SetPrint "│", 0
  370.    SetLocate -1, x1
  371. NEXT
  372.  
  373. SetLocate y1, x0
  374. SetPrint "└", 0
  375. FOR i = 1 TO xs - 2
  376.    SetPrint "─", 0
  377. NEXT
  378. SetPrint "┘", 1
  379.  
  380. SetColor tFG, tBG
  381.  
  382. END SUB
  383.  
  384. SUB ClearButtons (first, last)
  385.  
  386. 'clear buttons
  387.  
  388. FOR i = first TO last
  389.    ButtonSelect i, 0
  390. NEXT
  391.  
  392. END SUB
  393.  
  394. SUB DelayOnPort (times)
  395.  
  396. 'somewhat constant delay by reading through the IO bus
  397. 'times=10000 is about 1 second (50,000 INPs)
  398.  
  399. FOR i = 1 TO times
  400.    nix = INP(&H372)
  401.    nix = INP(&H372)
  402.    nix = INP(&H372)
  403.    nix = INP(&H372)
  404.    nix = INP(&H372)
  405. NEXT
  406.  
  407. END SUB
  408.  
  409. SUB DemoInit
  410.  
  411. CLS
  412.  
  413. SetColor 7, 0
  414. SetLocate 1, 1
  415.  
  416. gActiveButton = 1
  417.  
  418. 'get button info
  419. RESTORE ButtonInfo
  420. FOR i = 1 TO MAXBUTTONS
  421.    READ x0, y0, xs, ys
  422.    gButtonInfo(i).x0 = x0  'col
  423.    gButtonInfo(i).y0 = y0  'row
  424.    gButtonInfo(i).xs = xs  'cols
  425.    gButtonInfo(i).ys = ys  'rows
  426. NEXT
  427.  
  428. DrawPanel
  429.  
  430. MouseFunc 0, IM, OM: gMouse = OM.ax
  431. IM.cx = 296: IM.dx = 32: MouseFunc 4, IM, OM
  432. MouseOnOff 1
  433. ButtonSelect gActiveButton, 1
  434.  
  435. stat = SoundColdInit(-1)        'test FM music ability (use port 388h)
  436. IF stat = 0 THEN
  437.    gFMinit = 1    'FM okay
  438.    MusicInit 1    'start up the MIDI Music Player
  439. END IF
  440.  
  441. port = -1: irq = -1: DMA = 1
  442. stat = VOCinit(port, irq, DMA)  'test and auto configure SoundBlaster
  443. SetLocate 24, 45
  444. IF stat = 0 THEN
  445.    gVOCinit = 1   'VOC okay
  446.    SetPrint "IO:" + HEX$(port) + " IRQ:" + HEX$(irq), 0
  447. ELSE
  448.    SetPrint "IO:n/a", 0
  449. END IF
  450.  
  451. END SUB
  452.  
  453. SUB DoHelpInfo
  454.  
  455. 'about this program
  456.  
  457. MouseOnOff 0
  458. DoPauseMIDI 1
  459. REDIM sbuff(0 TO 2000)
  460. DEF SEG = &H0: t = PEEK(&H463): DEF SEG
  461. IF t = &HD4 THEN VideoSeg = &HB800 ELSE VideoSeg = &HB000
  462.  
  463. vseg = VARSEG(sbuff(0))
  464. voff = VARPTR(sbuff(0))
  465. FOR i = 0 TO 3999
  466.    DEF SEG = VideoSeg
  467.    vbyte = PEEK(i)
  468.    DEF SEG = vseg
  469.    POKE i, vbyte
  470. NEXT
  471. DEF SEG
  472. DoPauseMIDI 0
  473.  
  474. CLS
  475. PRINT "Press a key or mouse button to RETURN.─────────────────────────────────────────┐";
  476. PRINT "│                00000   To SELECT function use TAB/shift-TAB or Mouse        ∞│";
  477. PRINT "│   ┌─────────────│───────────────┐         ┌──────────────────────────────┐   │";
  478. PRINT "│   │        byte counter         │  EJECT  │                              │   │";
  479. PRINT "│   │                         ┌────>┌─┐ ┌─┐<────┐                          │   │";
  480. PRINT "│   │ Use to load a MIDI file ┘   │ └─┘ └─┘ │   └ Use to load a VOC file   │   │";
  481. PRINT "│   │                             │ ┌─┐ ┌─┐ │                              │   │";
  482. PRINT "│   │                         ┌────>└─┘ └─┘<─┐                             │   │";
  483. PRINT "│   │ Continuous-Auto Play ───┘   │   CAP   │└ either MIDI,VOC,or MIDI+VOC │   │";
  484. PRINT "│   └─────────────────────────────┘         └──────────────────────────────┘   │";
  485. PRINT "│     <<   PLAY   >>   STOP  PAUSE          REC  <<   PLAY   >>   STOP  PAUSE  │";
  486. PRINT "│    ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐          ┌─┐ ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐  │";
  487. PRINT "│∞   └──┘ └────┘ └──┘ └────┘ └───┘          └─┘ └──┘ └────┘ └──┘ └────┘ └───┘ ∞│";
  488. PRINT "│┌──────────────────────────────────┐∞  ∞┌───│────────────────────│────────│──┐│";
  489. PRINT "└┤ │  │  │  │  │  │  │  │  │  │  │  ├────┤   │                    │        │  ├┘";
  490. PRINT " │                                  │INFO│ Record and playback on-│the-spot│  │"
  491. PRINT " │ Each AdLib voice is tracked here │┌──┐│                        │        │  │"
  492. PRINT " │ during the playing of a MIDI file│└──┘│ If the tape 'jams' press STOP   │  │"
  493. PRINT " │                                  │    │                                 │  │"
  494. PRINT " │ The ▓ is the relative volume of  │QUIT│ Pause output anytime (toggled)     │"
  495. PRINT " │ the voice and  is the octave    │┌──┐│                                    │"
  496. PRINT " │                                  │└──┘│ SB configuration is auto-detected  │"
  497. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │ or │      │      │                      │"
  498. PRINT " │∞0  1  2  3  4  5  BD SD TT CY HH∞│ Esc│∞ IO:    IRQ:  (C)1991 Cornel Huth ∞│"
  499. PRINT " └──────────────────────────────────┘    └────────────────────────────────────┘";
  500.  
  501. DO
  502.    kbkey = GetKeyPick(0)
  503.    IF gMouse THEN
  504.       mbkey = GetMousePick(mbstate)
  505.       IF mbstate THEN kbkey = mbstate
  506.    END IF
  507. LOOP UNTIL kbkey
  508.  
  509. DoPauseMIDI 1
  510. vseg = VARSEG(sbuff(0))
  511. voff = VARPTR(sbuff(0))
  512. FOR i = 0 TO 3999
  513.    DEF SEG = vseg
  514.    vbyte = PEEK(i)
  515.    DEF SEG = VideoSeg
  516.    POKE i, vbyte
  517. NEXT
  518. DEF SEG
  519. DoPauseMIDI 0
  520. MouseOnOff 1
  521.  
  522. END SUB
  523.  
  524. SUB DoLoadMIDI
  525.  
  526. 'get MIDI filename
  527. 'load MIDI file into a 64K max buffer, mbuff(1..)
  528.  
  529. ON ERROR GOTO DiskHandler
  530. IF gFMinit = 0 THEN ERROR 249
  531. ON ERROR GOTO 0
  532.  
  533. GetInput "MIDI filename: ", filename$
  534. IF LEN(filename$) = 0 THEN EXIT SUB
  535.  
  536. SetLocate 9, 20
  537. tFG = gFG
  538. tBG = gBG
  539. SetColor 15, 0
  540. SetPrint UCASE$(RIGHT$(filename$ + SPACE$(12 - LEN(RIGHT$(filename$, 12))), 12)), 1
  541. SetColor tFG, tBG
  542.  
  543. ON ERROR GOTO DiskHandler
  544.  
  545. OPEN filename$ FOR INPUT AS #1  'error out before creating a new file
  546. CLOSE #1
  547.  
  548. OPEN filename$ FOR BINARY AS #1
  549. length& = LOF(1)
  550. IF length& > 65520 THEN ERROR 7
  551.  
  552. blocks = (length& \ 8192)
  553. IF length& MOD 8192 THEN blocks = blocks + 1
  554. REDIM mbuff(1 TO blocks) AS BigChunkTYPE
  555.  
  556. ss = 1
  557. DO WHILE NOT EOF(1)
  558.    GET #1, , mbuff(ss).BigChunk
  559.    ss = ss + 1
  560. LOOP
  561. CLOSE #1
  562.  
  563. ON ERROR GOTO 0
  564.  
  565. tapelen = (length& \ 16380) + 1
  566. SetLocate 6, 14
  567. SetPrint STRING$(5, " "), 0
  568. SetLocate 6, 14
  569. SetPrint STRING$(tapelen, ")"), 0
  570. gMIDIinit = 1
  571.  
  572. END SUB
  573.  
  574. SUB DoLoadVOC
  575.  
  576. 'get VOC filename
  577. 'load VOC file into a max buffer, vbuff(1..)
  578.  
  579. ON ERROR GOTO DiskHandler
  580. IF gVOCinit = 0 THEN ERROR 248
  581. ON ERROR GOTO 0
  582.  
  583. GetInput "VOC filename: ", filename$
  584. IF LEN(filename$) = 0 THEN EXIT SUB
  585.  
  586. SetLocate 9, 60
  587. tFG = gFG
  588. tBG = gBG
  589. SetColor 15, 0
  590. SetPrint UCASE$(RIGHT$(filename$ + SPACE$(12 - LEN(filename$)), 12)), 1
  591. SetColor tFG, tBG
  592.  
  593. ON ERROR GOTO DiskHandler
  594.  
  595. OPEN filename$ FOR INPUT AS #1  'error out before creating a new file
  596. CLOSE #1
  597.  
  598. OPEN filename$ FOR BINARY AS #1
  599. length& = LOF(1)
  600. IF length& > 524288 THEN ERROR 7
  601.  
  602. blocks = (length& \ 8192)
  603. IF length& MOD 8192 THEN blocks = blocks + 1
  604. REDIM vbuff(1 TO blocks) AS BigChunkTYPE
  605.  
  606. ss = 1
  607. DO WHILE NOT EOF(1)
  608.    GET #1, , vbuff(ss).BigChunk
  609.    ss = ss + 1
  610. LOOP
  611. CLOSE #1
  612.  
  613. ON ERROR GOTO 0
  614.  
  615. tapelen = (length& \ 65536) + 1
  616. IF tapelen > 5 THEN tapelen = 5
  617. SetLocate 6, 54
  618. SetPrint STRING$(5, " "), 0
  619. SetLocate 6, 54
  620. SetPrint STRING$(tapelen, ")"), 0
  621.  
  622. END SUB
  623.  
  624. SUB DoPauseMIDI (OnOff)
  625.  
  626. 'pause/continue playing of the MIDI file
  627.  
  628. IF gMIDIloaded = 0 THEN EXIT SUB
  629.  
  630. IF OnOff THEN
  631.    MusicPause
  632. ELSE
  633.    MusicCont
  634. END IF
  635.  
  636. END SUB
  637.  
  638. SUB DoPauseVOC (OnOff)
  639.  
  640. 'pause/continue playing of the VOC file
  641.  
  642. IF gVOCloaded = 0 THEN EXIT SUB
  643.  
  644. IF OnOff THEN
  645.    nix = VOCpause
  646. ELSE
  647.    nix = VOCcont
  648. END IF
  649.  
  650. END SUB
  651.  
  652. SUB DoPlayMIDI
  653.  
  654. 'play the MIDI file
  655.  
  656. IF gMIDIloaded = 0 THEN EXIT SUB
  657.  
  658. vseg = VARSEG(mbuff(1))
  659. voff = VARPTR(mbuff(1))
  660. stat = MusicPlay(vseg, voff)
  661.  
  662. END SUB
  663.  
  664. SUB DoPlayVoc
  665.  
  666. 'play the VOC file
  667.  
  668. IF gVOCloaded = 0 THEN EXIT SUB
  669.  
  670. stat = VOCinfo(CurrBlockType, CurrSampleRate)
  671. IF stat THEN EXIT SUB   'already active
  672.  
  673. vseg = VARSEG(vbuff(1))
  674. voff = VARPTR(vbuff(1))
  675. stat = VOCplay(vseg, voff)
  676.  
  677. END SUB
  678.  
  679. SUB DoRecordVOC
  680.  
  681. 'get VOC sample rate and seconds to record
  682. 'store VOC data into a max buffer, vbuff(1..)
  683. 'save it? left to the programmer (or use VoxKit)
  684.  
  685. ON ERROR GOTO DiskHandler
  686. IF gVOCinit = 0 THEN ERROR 248
  687. ON ERROR GOTO 0
  688.  
  689. MouseOnOff 0
  690. GetInput "Enter sample rate (5000-11000):", SampleRate$
  691. t& = VAL(SampleRate$)
  692. IF t& < 5000 THEN t& = 5000
  693. IF t& > 11000 THEN t& = 11000
  694. SR = CINT(t&)
  695. maxfre& = FRE(-1) - 64000
  696. maxsecs = maxfre& \ SR
  697. GetInput "Enter seconds to record (1-" + LTRIM$(STR$(maxsecs)) + "):", Second$
  698. t& = VAL(Second$)
  699. IF t& < 1 THEN t& = 1
  700. IF t& > maxsecs THEN t& = maxsecs
  701. rbytes& = t& * SR
  702.  
  703. blocks = (rbytes& \ 8192)
  704. IF rbytes& MOD 8192 THEN blocks = blocks + 1
  705. REDIM vbuff(1 TO blocks) AS BigChunkTYPE
  706.  
  707. GetInput "Press <Enter> to start recording", nix$
  708. vseg = VARSEG(vbuff(1))
  709. voff = VARPTR(vbuff(1))
  710. stat = VOCrecord(SR, rbytes&, vseg, voff)
  711. DO
  712.    stat = VOCinfo(CBT, CSR)
  713. LOOP WHILE stat
  714. GetInput "Press <Enter> to start playback", nix$
  715. stat = VOCplay(vseg, voff)
  716. DO
  717.    stat = VOCinfo(CBT, CSR)
  718. LOOP WHILE stat
  719.  
  720. REDIM vbuff(1 TO 1) AS BigChunkTYPE
  721. MouseOnOff 1
  722.  
  723. END SUB
  724.  
  725. SUB DoScreenMIDI STATIC
  726.  
  727. 'show MIDI info screen
  728.  
  729. DIM lastmode
  730. DIM VolInfo(0 TO 10)
  731. DIM NoteInfo(0 TO 10)
  732.  
  733. IF gMIDIloaded = 0 THEN EXIT SUB
  734.  
  735. stat = MusicInfo(0, note, vol, mode, MusicPtr&)
  736. IF MusicPtr& < 0 THEN MusicPtr& = 0
  737. SetLocate 2, 18
  738. SetPrint RIGHT$("00000" + LTRIM$(STR$(MusicPtr&)), 5), 1
  739.  
  740. IF lastmode <> (mode - 1) THEN
  741.    IF mode = 0 THEN
  742.       maxvoc = 8
  743.       SetLocate 24, 22
  744.       SetPrint "6  7  8       ", 0
  745.       lastmode = -1
  746.    ELSE
  747.       maxvoc = 10
  748.       SetLocate 24, 22
  749.       SetPrint "BD SD TT CY HH", 0
  750.       lastmode = -2
  751.    END IF
  752. END IF
  753.  
  754. ERASE VolInfo
  755. ERASE NoteInfo
  756. FOR voc = 0 TO maxvoc
  757.    stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  758.    IF vol > 127 THEN vol = 127     'MIDI levels
  759.    IF note > 127 THEN note = 127   ' "     "
  760.    IF stat THEN VolInfo(voc) = (vol + 1) \ 16
  761.    IF stat THEN NoteInfo(voc) = (note + 1) \ 16
  762. NEXT
  763.  
  764. FOR voc = 0 TO maxvoc
  765.    col = 4 + (voc * 3)
  766.    LOCATE 15, col
  767.    FOR i = 1 TO 9
  768.       LOCATE , col
  769.       PRINT "│ "
  770.    NEXT
  771.    LOCATE 23 - VolInfo(voc), col
  772.    IF VolInfo(voc) > 7 THEN COLOR 4, 0 ELSE COLOR 2, 0
  773.    PRINT "▓"
  774.    COLOR 7, 0
  775.    LOCATE 23 - NoteInfo(voc), col + 1
  776.    PRINT ""
  777. NEXT
  778.  
  779. END SUB
  780.  
  781. SUB DoScreenVOC
  782.  
  783. 'nyi
  784.  
  785. END SUB
  786.  
  787. SUB DoStopMIDI
  788.  
  789. 'shut down the MIDI Music Player
  790.  
  791. IF gMIDIinit THEN
  792.    MusicEnd     'shut it down
  793.    MusicInit 1  'start it back up
  794. END IF
  795.  
  796. END SUB
  797.  
  798. SUB DoStopVOC
  799.  
  800. 'shut down the VOC player
  801.  
  802. IF gVOCinit THEN nix = VOCend
  803.  
  804. END SUB
  805.  
  806. SUB DrawPanel
  807.  
  808. MouseOnOff 0
  809. VIEW PRINT 1 TO 25
  810. CLS
  811.       '123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-
  812. PRINT "┌──────────────────────────────────────────────────────────────────────────────┐";
  813. PRINT "│∞               00000                 ∞                 ......               ∞│";
  814. PRINT "│   ┌─────────────────────────────┐         ┌──────────────────────────────┐   │";
  815. PRINT "│   │                             │  EJECT  │                              │   │";
  816. PRINT "│   │      ┌───────────────┐      │ ┌─┐ ┌─┐ │      ┌────────────────┐      │   │";
  817. PRINT "│   │      │)             (│      │ └─┘ └─┘ │      │)              (│      │   │";
  818. PRINT "│   │      └───────────────┘      │ ┌─┐ ┌─┐ │      └────────────────┘      │   │";
  819. PRINT "│   │                             │ └─┘ └─┘ │                              │   │";
  820. PRINT "│   │  MIDI Track:                │   CAP   │   VOC Track:                 │   │";
  821. PRINT "│   └─────────────────────────────┘         └──────────────────────────────┘   │";
  822. PRINT "│     <<   PLAY   >>   STOP  PAUSE          REC  <<   PLAY   >>   STOP  PAUSE  │";
  823. PRINT "│    ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐          ┌─┐ ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐  │";
  824. PRINT "│∞   └──┘ └────┘ └──┘ └────┘ └───┘          └─┘ └──┘ └────┘ └──┘ └────┘ └───┘ ∞│";
  825. PRINT "│┌──────────────────────────────────┐∞  ∞┌────────────────────────────────────┐│";
  826. PRINT "└┤ │  │  │  │  │  │  │  │  │  │  │  ├────┤  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  ├┘";
  827. PRINT " │∞│  │  │  │  │  │  │  │  │  │  │ ∞│INFO│∞ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ∞│"
  828. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │┌──┐│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  829. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │└──┘│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  830. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │    │  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  │"
  831. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │QUIT│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  832. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │┌──┐│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  833. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │└──┘│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  834. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │    │  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  835. PRINT " │∞0  1  2  3  4  5  6  7  8  .  . ∞│    │∞ IO:    IRQ:  (C)1991 Cornel Huth ∞│"
  836. PRINT " └──────────────────────────────────┘    └────────────────────────────────────┘";
  837.       '123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-
  838.  
  839. MouseOnOff 1
  840.  
  841. END SUB
  842.  
  843. SUB FlashButton
  844.  
  845. 'flash the active button
  846.  
  847. ButtonSelect gActiveButton, 0
  848. DelayOnPort 500
  849. ButtonSelect gActiveButton, 1
  850. DelayOnPort 500
  851.  
  852. END SUB
  853.  
  854. SUB GetInput (prompt$, answer$)
  855.  
  856. 'get user input from line 1
  857.  
  858. SetLocate 1, 1
  859. SetPrint SPACE$(80), 0
  860. SetLocate 1, 1
  861. SetPrint prompt$, 0
  862. LINE INPUT answer$
  863. SetLocate 1, 1
  864. SetPrint "┌──────────────────────────────────────────────────────────────────────────────┐", 0
  865.  
  866. END SUB
  867.  
  868. FUNCTION GetKeyPick (waitfor)
  869.  
  870. 'get a key, if waitfor then wait until a key
  871.  
  872. DO
  873.    kb$ = INKEY$
  874.    kblen = LEN(kb$)
  875.    SELECT CASE kblen
  876.    CASE 0
  877.      kbkey = 0
  878.    CASE 1
  879.       kbkey = ASC(kb$)
  880.    CASE 2
  881.       kbkey = 1000 + ASC(RIGHT$(kb$, 1))
  882.    CASE ELSE
  883.    END SELECT
  884. LOOP UNTIL kbkey OR (waitfor = 0)
  885. GetKeyPick = kbkey
  886.  
  887. END FUNCTION
  888.  
  889. FUNCTION GetMousePick (MouseButtonState)
  890.  
  891. 'if mouse left button down and cursor is on a event button then
  892. 'set gActiveButton and return 13 else just return 0
  893.  
  894. 'bx=button status
  895. 'cx=horz cursor coor
  896. 'dx=vert cursor coor
  897.  
  898. MouseFunc 3, IM, OM
  899. MouseButtonState = OM.bx
  900.  
  901. match = 0
  902. IF OM.bx = 1 THEN
  903.    mx = OM.cx \ 8
  904.    my = OM.dx \ 8
  905.  
  906.    FOR i = 1 TO MAXBUTTONS
  907.       x0 = gButtonInfo(i).x0 - 1   '0-base it
  908.       y0 = gButtonInfo(i).y0 - 1
  909.       x1 = x0 + gButtonInfo(i).xs - 1
  910.       y1 = y0 + gButtonInfo(i).ys - 1
  911.  
  912.       'check for match in horz and vert positions
  913.  
  914.       IF mx >= x0 AND mx <= x1 THEN
  915.          IF my >= y0 AND my <= y1 THEN
  916.             gActiveButton = i
  917.             match = 13
  918.             EXIT FOR
  919.          END IF
  920.       END IF
  921.    NEXT
  922.  
  923. END IF
  924. GetMousePick = match
  925.  
  926. END FUNCTION
  927.  
  928. SUB MouseFunc (func, IM AS MouseTYPE, OM AS MouseTYPE)
  929.  
  930. 'hey, a complete mouse function routine
  931.  
  932. IF gMouse = 0 AND func > 0 THEN EXIT SUB
  933.  
  934. xreg.es = -1    'IM.ax used to pass ES segment register if needed
  935. SELECT CASE func
  936. CASE 0   'MOUSE RESET AND STATUS
  937.          'set: nothing
  938.          'rtn: ax=status (0=not found/not reset)
  939.          '     bx=buttons
  940.    DEF SEG = 0
  941.    MouseSeg = PEEK(206) + 256 * PEEK(207)
  942.    MouseOff = PEEK(204) + 256 * PEEK(205)
  943.    DEF SEG = MouseSeg
  944.    MouseExists = (MouseSeg <> 0 OR MouseOff <> 0) AND PEEK(MouseOff) <> &HCF
  945.    DEF SEG
  946.    IF MouseExists THEN xreg.ax = 0 ELSE OM.ax = 0: EXIT SUB
  947. CASE 1   'SHOW CURSOR
  948.          'set: nothing
  949.          'rtn: nothing
  950.    xreg.ax = 1
  951. CASE 2   'HIDE CURSOR
  952.          'set: nothing
  953.          'rtn: nothing
  954.    xreg.ax = 2
  955. CASE 3   'GET BUTTON STATUS AND MOUSE POS
  956.          'set: nothing
  957.          'rtn: bx=button status
  958.          '     cx=horz cursor coor
  959.          '     dx=vert cursor coor
  960.    xreg.ax = 3
  961. CASE 4   'SET MOUSE CURSOR POS
  962.          'set: cx=new horz cursor pos
  963.          '     dx=new vert cursor pos
  964.          'rtn: nothing
  965.    xreg.ax = 4
  966.    xreg.cx = IM.cx
  967.    xreg.dx = IM.dx
  968. CASE 5   'GET BUTTON PRESS INFO
  969.          'set: bx=button
  970.          'rtn: ax=button status
  971.          '     bx=number of button presses
  972.          '     cx=horz cursor coor at last press
  973.          '     dx=vert cursor coor at last press
  974.    xreg.ax = 5
  975.    xreg.bx = IM.bx
  976. CASE 6   'GET BUTTON RELEASE INFO
  977.          'set: bx=button
  978.          'rtn: ax=button status
  979.          '     bx=number of button releases
  980.          '     cx=horz cursor coor at last release
  981.          '     dx=vert cursor coor at last release
  982.    xreg.ax = 6
  983.    xreg.bx = IM.bx
  984. CASE 7   'SET MIN AND MAX HORZ CURSOR POS
  985.          'set: cx=min pos
  986.          '     dx=max pos
  987.          'rtn: nothing
  988.    xreg.ax = 7
  989.    xreg.cx = IM.cx
  990.    xreg.dx = IM.dx
  991. CASE 8   'SET MIN AND MAX VERT CURSOR POS
  992.          'set: cx=min pos
  993.          '     dx=max pos
  994.          'rtn: nothing
  995.    xreg.ax = 8
  996.    xreg.cx = IM.cx
  997.    xreg.dx = IM.dx
  998. CASE 9   'SET GRAPHICS CURSOR BLOCK
  999.          'set: ax=segment of cursor mask (NEVER DEFAULT)
  1000.          '     bx=horz cursor hot spot
  1001.          '     cx=vert cursor hot spot
  1002.          '     dx=pointer to screen
  1003.          'rtn: nothing
  1004.    xreg.ax = 9
  1005.    xreg.bx = IM.bx
  1006.    xreg.cx = IM.cx
  1007.    xreg.dx = IM.dx
  1008.    xreg.es = IM.ax
  1009. CASE 10  'SET TEXT CURSOR
  1010.          'set: bx=cursor select
  1011.          '     cx=screen mask value or scan line start
  1012.          '     dx=cursor mask value or scan line start
  1013.          'rtn: nothing
  1014.    xreg.ax = 10
  1015.    xreg.bx = IM.bx
  1016.    xreg.cx = IM.cx
  1017.    xreg.dx = IM.dx
  1018. CASE 11  'READ MOUSE MOTION COUNTERS
  1019.          'set: nothing
  1020.          'rtn: cx=horz mickey count
  1021.          '     dx=vert mickey count
  1022.    xreg.ax = 11
  1023. CASE 12  'SET INTERRUPT SUBROUTINE CALL MASK AND ADDRESS
  1024.          'set: ax=segment of subroutine (NEVER DEFAULT)
  1025.          '     cx=call mask.........bit 0-cursor pos changed
  1026.          '     dx=offset of subroutine '1-left button pressed
  1027.          'rtn: nothing                 '2-left button released
  1028.    xreg.ax = 12                        '3-right button pressed
  1029.    xreg.cx = IM.cx                     '4-right button released
  1030.    xreg.dx = IM.dx                     '5-15 not used
  1031.    xreg.es = IM.ax
  1032. CASE 13  'LIGHT PEN EMULATION MODE ON
  1033.          'set: nothing
  1034.          'rtn: nothing
  1035.    xreg.ax = 13
  1036. CASE 14  'LIGHT PEN EMULATION MODE OFF
  1037.          'set: nothing
  1038.          'rtn: nothing
  1039.    xreg.ax = 14
  1040. CASE 15  'SET MICKEY/PIXEL RATIO
  1041.          'set: cx=horz mickey to pixel ratio
  1042.          '     dx=vert mickey to pixel ratio
  1043.          'rtn: nothing
  1044.    xreg.ax = 15
  1045.    xreg.cx = IM.cx
  1046.    xreg.dx = IM.dx
  1047. CASE 16  'CONDITIONAL OFF
  1048.          'set: ax=left x (slightly different than regular calling registers)
  1049.          '     bx=upper y
  1050.          '     cx=right x
  1051.          '     dx=lower y
  1052.          'rtn: nothing
  1053.    xreg.ax = 16
  1054.    xreg.cx = IM.ax
  1055.    xreg.dx = IM.bx
  1056.    xreg.si = IM.cx
  1057.    xreg.di = IM.dx
  1058. CASE 17, 18
  1059. CASE 19  'SET DOUBLE-SPEED THRESHOLD
  1060.          'set: dx=threshold speed in mickeys/seconds
  1061.          'rtn: nothing
  1062.    xreg.ax = 19
  1063.    xreg.dx = IM.dx
  1064. CASE 20  'SWAP INTERRUPT ROUTINES
  1065.          'set: ax=segment of subroutine (NEVER DEFAULT)
  1066.          '     cx=call mask (as in func 12 above)
  1067.          '     dx=offset of subroutine        ***********************
  1068.          'rtn: bx=segment of old subroutine   *Rtn values valid only*
  1069.          '     cx=call mask of old subroutine *if previous interrupt*
  1070.          '     dx=offset of old subroutine    *was created          *
  1071.    xreg.ax = 20                              '***********************
  1072.    xreg.cx = IM.cx
  1073.    xreg.dx = IM.dx
  1074.    xreg.es = IM.ax
  1075.    INTERRUPTX &H33, xreg, xreg
  1076.    OM.ax = 0
  1077.    OM.bx = xreg.es
  1078.    OM.cx = xreg.cx
  1079.    OM.dx = xreg.dx
  1080.    EXIT SUB
  1081. CASE 21  'GET MOUSE DRIVER STATE STORAGE REQUIREMENTS
  1082.          'set: nothing
  1083.          'rtn: bx=buffer size in bytes
  1084.    xreg.ax = 21
  1085. CASE 22  'SAVE MOUSE DRIVER STATE
  1086.          'set: ax=segment of buffer
  1087.          '     dx=offset of buffer
  1088.          'rtn: nothing
  1089.    xreg.ax = 22
  1090.    xreg.dx = IM.dx
  1091.    xreg.es = IM.ax
  1092. CASE 23  'RESTORE MOUSE DRIVER STATE
  1093.          'set: ax=segment of buffer
  1094.          '     dx=offset of buffer
  1095.          'rtn: nothing
  1096.    xreg.ax = 23
  1097.    xreg.dx = IM.dx
  1098.    xreg.es = IM.ax
  1099. CASE 24  'SET ALTERNATE SUBROUTINE CALL MASK AND ADDRESS
  1100.          'set: ax=segment of user subroutine
  1101.          '     cx=call mask.........bit 0-cursor pos changed
  1102.          '     dx=offset of subroutine '1-left button pressed
  1103.          'rtn: ax=error status (-1)    '2-left button released
  1104.    xreg.ax = 24                        '3-right button pressed
  1105.    xreg.cx = IM.cx                     '4-right button released
  1106.    xreg.dx = IM.dx                     '5-shift key down w/button
  1107.    xreg.es = IM.ax                     '6-ctrl key down w/button
  1108.                                        '7-alt key down w/button
  1109.                                        '8-15 not used
  1110. CASE 25  'GET USER ALTERNATE INTERRUPT ADDRESS
  1111.          'set: cx=user interrupt call mask
  1112.          'rtn: ax=error status (-1)
  1113.          '     bx=segment of user subroutine
  1114.          '     cx=call mask of user interrupt
  1115.          '     dx=offset of subroutine
  1116.    xreg.ax = 25
  1117.    xreg.cx = IM.cx
  1118. CASE 26  'SET MOUSE SENSITIVITY
  1119.          'set: bx=horz mickey sensitivity (0 to 100)  these all
  1120.          '     cx=vert mickey sensitivity (0 to 100)   have default
  1121.          '     dx=threshold for double speed (0 to 100) values=50
  1122.          'rtn: nothing
  1123.    xreg.ax = 26
  1124.    xreg.bx = IM.bx
  1125.    xreg.cx = IM.cx
  1126.    xreg.dx = IM.dx
  1127. CASE 27  'GET MOUSE SENSITIVITY
  1128.          'set: nothing
  1129.          'rtn: bx=horz mickey sensitivity (0 to 100)
  1130.          '     cx=vert mickey sensitivity (0 to 100)
  1131.          '     dx=threshold for double speed (0 to 100)
  1132.    xreg.ax = 27
  1133. CASE 28  'SET MOUSE INTERRUPT RATE (InPort mouse ONLY)
  1134.          'set: bx=rate number (0 (0/sec) to 4 (200/sec))
  1135.          'rtn: nothing
  1136.    xreg.ax = 28
  1137.    xreg.bx = IM.bx
  1138. CASE 29  'SET CRT PAGE NUMBER
  1139.          'set: bx=CRT page for mouse cursor display
  1140.          'rtn: nothing
  1141.    xreg.ax = 29
  1142.    xreg.bx = IM.bx
  1143. CASE 30  'GET CRT PAGE NUMBER
  1144.          'set: nothing
  1145.          'rtn: bx=CRT page for current mouse cursor display
  1146.    xreg.ax = 30
  1147. CASE 31  'DISABLE MOUSE DRIVER
  1148.          'set: nothing
  1149.          'rtn: ax=error status (-1)
  1150.          '     bx=segment of old int 33h
  1151.          '     dx=offset of old int 33h
  1152.    xreg.ax = 31
  1153.    INTERRUPTX &H33, xreg, xreg
  1154.    OM.ax = xreg.ax
  1155.    OM.bx = xreg.es
  1156.    OM.cx = 0
  1157.    OM.dx = xreg.bx
  1158.    EXIT SUB
  1159. CASE 32  'ENABLE MOUSE DRIVER
  1160.          'set: nothing
  1161.          'rtn: nothing
  1162.    xreg.ax = 32
  1163. CASE 33  'SOFTWARE RESET
  1164.          'set: nothing
  1165.          'rtn: ax=-1 (or 33 if mouse drive not installed)
  1166.          '     bx=2 (if ax=-1. Must=2 for a valid reset)
  1167.    xreg.ax = 33
  1168. CASE 34  'SET LANGUAGE FOR MESSAGES (International MOUSE.xxx ONLY)
  1169.          'set: bx=language number
  1170.          'rtn: nothing
  1171.    xreg.ax = 34
  1172.    xreg.bx = IM.bx
  1173. CASE 35  'GET LANGUAGE NUMBER
  1174.          'set: nothing
  1175.          'rtn: bx=language number
  1176.    xreg.ax = 35
  1177. CASE 36  'GET DRIVER VERSION,MOUSE TYPE,AND IRQ NUMBER
  1178.          'set: nothing
  1179.          'rtn: bx=mouse driver version number
  1180.          '        bh=major
  1181.          '        bl=minor
  1182.          '     cx=mouse type and IRQ number
  1183.          '        ch=mouse type (1=bus,2=serial,3=InPort,4=PS/2,5=HP)
  1184.          '        cl=IRQ number (0=PS/2, 2-5 or 7=mouse IRQ)
  1185.    xreg.ax = 36
  1186. CASE ELSE
  1187.    OM.ax = 0
  1188.    OM.bx = 0
  1189.    OM.cx = 0
  1190.    OM.dx = 0
  1191.    EXIT SUB
  1192. END SELECT
  1193.  
  1194. INTERRUPTX &H33, xreg, xreg
  1195. OM.ax = xreg.ax
  1196. OM.bx = xreg.bx
  1197. OM.cx = xreg.cx
  1198. OM.dx = xreg.dx
  1199.  
  1200. END SUB
  1201.  
  1202. SUB MouseOnOff (OnOff)
  1203.  
  1204. 'turn the mouse cursor on/off
  1205.  
  1206. IF OnOff THEN
  1207.    MouseFunc 1, IM, OM  'show
  1208. ELSE
  1209.    MouseFunc 2, IM, OM  'hide
  1210. END IF
  1211.  
  1212. END SUB
  1213.  
  1214. FUNCTION SelectEvent
  1215.  
  1216. 'determine what's going to happen
  1217.  
  1218. tActiveButton = gActiveButton
  1219.  
  1220. 'read the keyboard for event keys
  1221. '-TABs select active button
  1222. '-ENTER performs active button
  1223. '-mouse supported (left button=select and perform)
  1224.  
  1225. kbkey = GetKeyPick(0)
  1226. IF gMouse THEN
  1227.    mbkey = GetMousePick(mbstate)
  1228.    IF mbkey THEN kbkey = mbkey
  1229. END IF
  1230.  
  1231. SELECT CASE kbkey
  1232. CASE 0
  1233. CASE 9       'TAB->
  1234.    gActiveButton = gActiveButton + 1
  1235.    IF gActiveButton > MAXBUTTONS THEN gActiveButton = 1
  1236. CASE 1015    '<-TAB
  1237.    gActiveButton = gActiveButton - 1
  1238.    IF gActiveButton = 0 THEN gActiveButton = MAXBUTTONS
  1239. CASE 1059    'F1
  1240.    DoHelpInfo
  1241. CASE 13
  1242.    ExitSub = 13
  1243. CASE 27
  1244.    ExitSub = 27
  1245. CASE ELSE
  1246. END SELECT
  1247.  
  1248. IF kbkey THEN
  1249.    ButtonSelect tActiveButton, 0
  1250.    ButtonSelect gActiveButton, 1
  1251.    tActiveButton = gActiveButton
  1252.    IF ExitSub = 13 THEN FlashButton
  1253. END IF
  1254.  
  1255. SelectEvent = ExitSub
  1256.  
  1257. END FUNCTION
  1258.  
  1259. SUB SetAutoPlay
  1260.  
  1261. 'put the appropriate autoplay icons on the panel
  1262.  
  1263. DIM tstr AS STRING * 5
  1264. DIM LA AS STRING * 1
  1265. DIM RA AS STRING * 1
  1266.  
  1267. tstr = " CAP "
  1268. LA = CHR$(17)
  1269. RA = CHR$(16)
  1270.  
  1271. tFG = gFG
  1272. tBG = gBG
  1273. SetColor 15, 0
  1274. SELECT CASE gAutoPlay
  1275. CASE 0
  1276.    SetColor 7, 0
  1277. CASE 1
  1278.    MID$(tstr, 1, 1) = LA
  1279. CASE 2
  1280.    MID$(tstr, 5, 1) = RA
  1281. CASE 3
  1282.    MID$(tstr, 1, 1) = LA
  1283.    MID$(tstr, 5, 1) = RA
  1284. CASE ELSE
  1285. END SELECT
  1286. SetLocate 9, 38
  1287. SetPrint tstr, 0
  1288. SetColor tFG, tBG
  1289.  
  1290. END SUB
  1291.  
  1292. SUB SetColor (fore, back)
  1293.  
  1294. 'all color changes come through here so we can track what's current
  1295.  
  1296. gFG = fore
  1297. gBG = back
  1298. MouseOnOff 0
  1299. COLOR fore, back
  1300. MouseOnOff 1
  1301.  
  1302. END SUB
  1303.  
  1304. SUB SetLocate (row, col)
  1305.  
  1306. 'all locate changes come through here so we can track what's current
  1307.  
  1308. MouseOnOff 0
  1309. IF row > 0 THEN gRow = row
  1310. IF col > 0 THEN gCol = col
  1311. IF row > 0 AND col > 0 THEN
  1312.    LOCATE row, col
  1313. ELSEIF row <= 0 AND col > 0 THEN
  1314.    LOCATE , col
  1315. ELSEIF row > 0 AND col <= 0 THEN
  1316.    LOCATE row
  1317. END IF
  1318. MouseOnOff 1
  1319.  
  1320. END SUB
  1321.  
  1322. SUB SetPrint (strg$, CR)
  1323.  
  1324. 'need to shuffle PRINTs through here so to turn off the mouse cursor
  1325.  
  1326. MouseOnOff 0
  1327. IF CR = 0 THEN PRINT strg$;  ELSE PRINT strg$
  1328. MouseOnOff 1
  1329.  
  1330. END SUB
  1331.  
  1332. SUB SoundEffects (effnumber)
  1333.  
  1334. 'we can interrupt the playing MIDI file and pump out some interesting
  1335. 'sounds (but we have to preserve the FM chip state, easy enough since
  1336. 'there's a built-in QBXSOUND function
  1337. 'just play around with this
  1338.  
  1339. MusicPause
  1340. StateSave
  1341. 'SetSoundMode 0
  1342. InitSlotParms  'w/SoundWarmInit
  1343. SELECT CASE effnumber
  1344. CASE 1  'a very fast rewind
  1345.    FOR note = 75 TO 127
  1346.       NoteOn 0, note
  1347.       DelayOnPort 100
  1348.       NoteOff 0
  1349.    NEXT
  1350. CASE 2  'a high freq
  1351.   NoteOn 0, 127
  1352.   DelayOnPort 1000
  1353.   NoteOff 0
  1354. CASE ELSE
  1355. END SELECT
  1356. StateRestore
  1357. MusicCont
  1358.  
  1359. END SUB
  1360.  
  1361.